<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>demo09-组件-数据单例-问题隐患</title>
</head>
<script src="../libs/vue.js"></script>
<body> 
    <div id="app"> 
        <button-counter-shared></button-counter-shared>
        <button-counter-shared></button-counter-shared>
        <button-counter-shared></button-counter-shared>
    </div>
</body>
<script>
Vue.config.productionTip = false;
Vue.component('button-counter-shared', {
  data: { 
      /**
       * 在2.6.14中已经禁止使用此方式。组件中的data一律返回 function
       */
    count: 0
  },
  template: '<button v-on:click="docount">You clicked me {{ mycount }} times.</button>',
  computed:{
      mycount:function(){
        //   return 0
        var thiscount = this.count
        //   return this.count
        return thiscount
      }
  },
  methods:{
      docount:function(){
          this.count++;
      }
  }
});

var app = new Vue({
  el: '#app',
});

</script>
</html>